﻿using System;

namespace BankBal {
    class Program {
        static void Main(string[] args)
        {
            double bal = 10000.0;
            double withdrawls = 0;
            double deposits = 0;
            double tax = 0;
            double taxrate = 0;
            double diff = 0;
            double total = 0;
            bool numValid;

            do
            {
                numValid = true;
                try
                {
                    Console.WriteLine("Enter total withdrawls for the month: ");
                    withdrawls = Convert.ToDouble(Console.ReadLine());
                }
                catch (FormatException nfe)
                {
                    nfe = new FormatException("Please enter a numberic withdraw amount.");
                    Console.WriteLine("ERROR! {0}", nfe);
                    numValid = false;
                }
            } while (!numValid);

            do
            {
                numValid = true;
                try
                {
                    Console.WriteLine("Enter total deposits for the month: ");
                    deposits = Convert.ToDouble(Console.ReadLine());
                }
                catch (FormatException nfe)
                {
                    nfe = new FormatException("Please enter a numberic deposit amount.");
                    Console.WriteLine("ERROR! {0}", nfe);
                    numValid = false;
                }
            } while (!numValid);

            do
            {
                numValid = true;
                try
                {
                    Console.WriteLine("Enter tax rate applied: ");
                    taxrate = Convert.ToDouble(Console.ReadLine());
                }
                catch (FormatException nfe)
                {
                    nfe = new FormatException("Bad tax Value!");
                    Console.WriteLine("ERROR! {0}", nfe);
                    numValid = false;
                }
            } while (!numValid);

            diff = (withdrawls - deposits);
            tax = ((withdrawls + deposits) * taxrate);
            total = bal - diff - tax;

            Console.WriteLine("The new balance at the end of the moneth is : {0}", total);
            Console.ReadKey(true);
        }
    }
}
